package com.zhuang.chapter11.work06;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegexData {
	public static void main(String[] args) {
		String s1 = "欢迎来到南京XX学院学习，电话:18512516785,18512508079" + "或者联系邮箱：baaaiu@cucu.cn"
				+ "座机电话：025-36517899,025-98951256，" + "邮箱：bozai@cucu.cn"
				+ "热线电话：400-618-8080，400-618-6000，400-618-4000";
		// 0\\d{2,6}-?\\d{5,20})|(1[3-9]\\d{9}) 座机电话和电话的匹配
		// (\\w{1,30}@[0-9a-zA-z]{2,20}(\\.[0-9a-zA-Z]{2,20}){1,2}) 域名的匹配
		// (400-?\\d{3,20}-?\\d{3,20}) 400电话的匹配
		String regex = "(0\\d{2,6}-?\\d{5,20})|(1[3-9]\\d{9})|"
				+ "(\\w{1,30}@[0-9a-zA-z]{2,20}(\\.[0-9a-zA-Z]{2,20}){1,2})|" + "(400-?\\d{3,20}-?\\d{3,20})";
		Pattern pattern = Pattern.compile(regex);
		Matcher matcher = pattern.matcher(s1);
		while (matcher.find()) {
			System.out.println(matcher.group());
		}
	}
}
